<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.lable.expertSTDsee"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
	<style type="text/css">
	.content .box .form-inline .form-group select {
	    max-width: 268px;
	}
	</style>
    <!--[if lt IE 9]>
        <script src="${ctx}/lib/js/html5shiv.min.js"></script>
        <script src="${ctx}/lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
                            
    <section class="content-header">
        <h1><spring:message code="message.lable.expertSTDsee"/></h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.StdManage"/></a></li>
            <li class="active"><a href=""><spring:message code="message.lable.expertStd"/></a></li>
        </ol>
    </section>
    
    <section class="content">
     <form action="${ctx}/stdExpert/exportExcel.html" id="exportExcel" method="post"> 
     <input id="fileName" name="fileName" type="hidden" value="<spring:message code="message.lable.expertxls"/>" />    
	       <div class=" box box-success">
				<div class="box-body"  >
				    <div class="input">
				       <div class="textalign1"><spring:message code="message.listForm.zhuanJiaXingming"/>：</div>
		               <div class="boxinput">
		                        <input type="text" class="textinput" id="name" name="name" placeholder="<spring:message code="message.listForm.zhuanJiaXingming"/>" maxlength="64"/>
		               </div>	
		               <div class="textalign"><spring:message code="message.listForm.danWei"/>：</div>
		               <div class="boxinput">
		                        <input type="text" class="textinput" id="companyId" name="companyId" placeholder="<spring:message code="message.listForm.danWei"/>" maxlength="200"/>
		               </div>
		               <div class="textalign"><spring:message code="message.lable.status"/>：</div>
		               <div class="boxinput">
		                        <select class="textinput " name="status" id="status">
		                            <option value=""><spring:message code="message.select.option"/></option>
		                            <option value="1"><spring:message code="message.button.start"/></option>
		                            <option value="2"><spring:message code="message.button.stop"/></option>
		                        </select>
		               </div>	   
				    </div>
				    <div class="input" style="margin-top:-5px">
				       <div class="textalign1"><spring:message code="message.listForm.zhuanYeJiShuTeChang"/>：</div>
		               <div class="boxinput">
		                 <table style="width:100%;">
		                   <tr>
		                     <td style="width:33%">
		                        <select id="expSkillsType1" name="expSkills" class="textinput" ></select>
		                     </td>
		                     <td style="width:33%">
		                        <select id="expSkillsType2" name="expSkills" class="textinput" ></select>
		                     </td>
		                     <td style="width:33%">  
		                        <select id="expSkillsType3" name="expSkills" class="textinput" ><option value=""><spring:message code="message.select.option"/> </option></select>
		                     </td>
		                    </tr>
		                  </table>
		               </div>
		               <div class="textalign">
				             <button type="button" class="btn btn-success btn-sm" onclick="search();" id="searchpharname"><spring:message code="message.button.seachSpacing"/></button>
				       </div>
				    </div>
				</div>
		   </div>	    
        </form>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        
        <div class=" box box-warning bottongroup">
             <ms:btn url="/stdExpert/add.html"><a href="${ctx}/stdExpert/add.html?opType=0" class="btn btn-default btn-sm"><spring:message code="message.button.addSpacing"/></a></ms:btn>
             <ms:btn url="/stdExpert/enable.html"><label class="btn btn-default btn-sm" onclick="batchChangeStatus(1)"><spring:message code="message.button.startSpacing"/></label></ms:btn>
             <ms:btn url="/stdExpert/disable.html"><label class="btn btn-default btn-sm" onclick="batchChangeStatus(0)"><spring:message code="message.button.stopSpacing"/></label></ms:btn>
             <label onclick="exportExcel();" class="btn btn-default btn-sm"><spring:message code="message.lable.daoChu"/></label>
        </div>
  
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    
    <script type="text/javascript">
        
    //绑定回车
    $('#expSkills,#name,#companyId,#status,#expSkillsType1,#expSkillsType2,#expSkillsType3').bind('keydown', function(event) {
        if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
            $('#searchpharname').click();
        }
    }); 
  
    $("#name").focus();//加载页面光标在第一个查询框内
    
   
    function batchChangeStatus(flag) {
		var msg = "<spring:message code='message.button.start' />";
		var url = "${ctx}/stdExpert/disable.html"
    	if (flag == 0){
    		msg = "<spring:message code='message.button.stop' />";
    		 url = "${ctx}/stdExpert/enable.html"
    	}
    	//获取选中的ID及对应的名字（参数:jqgridId,名字列名，状态列名，当前操作即列表中显示的值），返回infos[0]是ID串，infos[1]是名字串
    	var infos = batchSwitchStatus("gridlist","name","status",msg,"<spring:message code='message.lable.userzhuanjia'/>");
    	if ( !(infos instanceof Array)){
    		return;
    	}
    	 var str = new Array();
    	 var list =[];
    	 str=infos[0].split(",");
		 for(var i=0;i<str.length;i++){
			 list.push({"expertId":str[i],"status":flag});
		 }    
		 console.log(list);
  	    $.HN.message.confirm('<spring:message code='message.button.confirm' />'+msg+'<spring:message code='message.HN.alert.yiXiaZhuanJia' /><spring:message code='message.yanZheng.wenHao' /><br/>'+infos[1].replace(/\,/g,"<br/>"), '', '').on(function (e) {
            if (e) {
				
            	$.ajax({
                    url: url,//action地址
                    data: {"array":json.jsonToString(list)},
                    type: "post",//执行方式get or post 默认以post方式执行
                    dataType:"json",
                    success: function (result) {//执行成功后 提示
                        if (result.success){
                        	top.$.HN.message.alert("<spring:message code='message.HN.alert.chengGongCaoZuo' />"+infos[0].split(",").length+"<spring:message code='message.HN.alert.tiaoShuJu' /><spring:message code="message.yanZheng.ganTanHao"/>","", "success");
                           search( $("#gridlist").getGridParam("page"));
                        } else {
                    	   top.$.HN.message.alert("<spring:message code='message.HN.alert.fail' /><spring:message code="message.yanZheng.ganTanHao"/>","", "error");
                        } 
                    }
                });
            }
        });
	}
     
        //查询
        function search(page) {
        	var expSkillsType1 = $("#expSkillsType1").val();
            var expSkillsType2 = $("#expSkillsType2").val();
            var expSkillsType3 = $("#expSkillsType3").val();
            var name = $("#name").val();
            var companyId = $("#companyId").val();
            var status = $("#status").val();
            $("#gridlist").jqGrid('setGridParam',{  
                datatype:'json',
                postData:{
                    "expSkillsType1":expSkillsType1,
                    "expSkillsType2":expSkillsType2,
                    "expSkillsType3":expSkillsType3,
                    "name":name,
                    "companyId":companyId,
                    "status":status
                    },
                page : (page || 1)
            }).trigger("reloadGrid"); //重新载入  
        }
    
        $(function () {
            $("#gridlist").jqGrid({
                url: "${ctx}/stdExpert/getExpertList.html",
                mtype: "post",
                datatype: "json",
                autowidth: true,
                height: 270,

                colNames: ['<spring:message code="message.jqGrid.cz"/>',
                           '<spring:message code="message.listForm.zhuanJiaBianMa"/>',
                           '<spring:message code="message.listForm.zhuanJiaXingming"/>',
                           '<spring:message code="message.listForm.xingbie"/>',
                           '<spring:message code="message.listForm.zhuanJiaLeiBie"/>', 
                           '<spring:message code="message.listForm.zhiWu"/>',
                           '<spring:message code="message.listForm.danWei"/>', 
                           '<spring:message code="message.listForm.lianXiDianHua"/>',
                           '<spring:message code="message.listForm.chuShengRiQi"/>', 
                           '<spring:message code="message.lable.status"/>',
                           ],

                colModel: [

                    { name: 'operate', width: 100, align:"center", sortable: false,
                        formatter : function(val, opts, rowdata) {
                        	var str =  "<ms:btn url='/stdExpert/edit.html'><a href='${ctx}/stdExpert/edit.html?opType=1&expertId=" + rowdata.expertId + "' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat 0px 0px' class='opIcon' title='<spring:message code="message.jqGrid.cz.bianJi"/>'></a></ms:btn>";
                            str += "<ms:btn url='/stdExpert/toStdExpertDetail.html'><a href='${ctx}/stdExpert/toStdExpertDetail.html?expertId=" + rowdata.expertId + "' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -100px 0px' class='opIcon' title='<spring:message code="message.jqGrid.cz.xiangQing"/>'></a></ms:btn>";
                            str += "<ms:btn url='/stdExpert/exPertLogList.html'><a href='${ctx}/stdExpert/exPertLogList.html?expertId=" + rowdata.expertId + "&expertCode="+rowdata.expertCode+"&name="+rowdata.name+"' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -120px 0px' class='opIcon' title='<spring:message code="message.jqGrid.cz.weiHuJiLu"/>'></a></ms:btn>";
                            return str;
                            }
                    },

                    { name: 'expertCode', width: 80, align:"center", sortable: false},
                    { name: 'name', width: 80, align:"center", sortable: false },
                    { name: 'sex', width: 40, align:"center", sortable: false},
                    { name: 'expSkills', width: 80, align:"center", sortable: false},
                    { name: 'position', width: 80, align:"center", sortable: false},
                    { name: 'companyId', width: 160, align:"left", sortable: false},
                    { name: 'handphone', width: 120, align:"center", sortable: false},

                    { name: 'birthday', width: 80, align:"center", sortable: false},
                    { name: 'status', width: 40, align: 'center', sortable: false,
                        formatter:function(val, opts, rowdata){
                        if (val == 1){
                            return "<spring:message code="message.button.start"/>";
                        } else if (val == 0){
                            return "<span class='red'><spring:message code="message.button.stop"/></span>";
                        }
                    }   
                    }
                    

                ],
                rowNum: 20,
                rowList: [10, 20, 50,100],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: true, 
                viewrecords: true,
                caption: "<spring:message code="message.list.expertStdlist"/>",
                //序号宽度自动变化
                gridComplete:function(){        
                    var page = $("#gridlist").jqGrid('getGridParam','page');
                    var rows = $('#gridlist').getGridParam("rowNum");
                    var maxnum = (rows*page).toString();
                    var len = (maxnum.length)*10;
                    $('.jqgfirstrow').find('td').eq(0).css('width',len+'px');
                    $('#gridlist_rn').css('width',len+'px');
                    
                  //单条数据自动选中
                	var rowIds = $("#gridlist").jqGrid('getDataIDs');
                	if(rowIds.length==1){
                		$("#"+rowIds[0]).click();
                	}
                },
                jsonReader: {
                    id: "expertId"
                }
            });
            
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
            //moreNoMore();
            
            $("#expSkillsType1").HNSelect({
                url: "${ctx}/selectController/getExpertType.html", data: { ID: '0' },  defaultText: "<option value=''>请选择</option>",
                func: function () {
                    $("#expSkillsType2").HNSelect({
                        parent_selector: "#expSkillsType1", url: "${ctx}/selectController/getExpertType.html", dataid: "ID",defaultText: "<option value=''>请选择</option>",
                                  func: function () {
                                      $("#expSkillsType3").HNSelect({
                                          parent_selector: "#expSkillsType2", url: "${ctx}/selectController/getExpertType.html", dataid: "ID", defaultText: "<option value=''>请选择</option>"
                                      });
                                  }
                    });
                }
            });

            
            
            
        });
        
        /**
         *维护记录链接触发到维护记录页面
         */
         function WHjsp(){
          window.location.href="${ctx}/stdExpert/expertLogList.html";
         }
  function exportExcel(){
     		$.HN.message.confirm('<spring:message code="message.lable.OKExport"/>&nbsp;<spring:message code="message.lable.expertxls"/>&nbsp;<spring:message code="message.lable.ma"/>', '', '').on(function (e) {
 	               if (e) {
 	            		  $("#exportExcel").submit();
 			
 	               }
          	 }); 
          	
     	}     </script>
</body>
</html>

